package com.netcracker.training.oracle.dao.common;

import com.netcracker.training.oracle.dao.manager.DBException;
import com.netcracker.training.oracle.dao.manager.DBManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @author olhr0713
 */
public abstract class AbstractDao {

    protected DBManager dBManager;

    public AbstractDao(DBManager dBManager) {
        this.dBManager = dBManager;
    }

    protected void close(ResultSet resultSet) throws DBException {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException ex) {
                throw new DBException(ex.getMessage(), ex);
            }
        }
    }

    protected void close(Statement statement) throws DBException {
        if (statement != null) {
            try {
                statement.close();
            } catch (SQLException ex) {
                throw new DBException(ex.getMessage(), ex);
            }
        }
    }
}